//
//  LBBuyCardetailsCell.m
//  loveBeen
//
//  Created by 杨烁 on 2016/11/20.
//  Copyright © 2016年 loveBeen. All rights reserved.
//

#import "LBBuyCardetailsCell.h"
#import "LBMinusPlusView.h"


@interface LBBuyCardetailsCell()
@property (weak, nonatomic) IBOutlet UIImageView *icon;
@property (weak, nonatomic) IBOutlet UILabel *name;
@property (weak, nonatomic) IBOutlet UILabel *price;
@property (weak, nonatomic) IBOutlet UILabel *jx_label;
@property(weak,nonatomic)LBMinusPlusView  *MPView;

@property (weak, nonatomic) IBOutlet UIButton *selectBtn;
//约束
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *jx_weight;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *name_leading;

@end
@implementation LBBuyCardetailsCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    LBMinusPlusView *view = [[[UINib nibWithNibName:@"LBMinusPlusView" bundle:nil] instantiateWithOwner:nil options:nil] lastObject];
    [self.contentView addSubview:view];
    
    self.MPView = view;
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-10);
        make.bottom.offset(-7);
        make.size.mas_equalTo(CGSizeMake(84, 30));
    }];
}

-(void)setModel:(LBSuperMarketProducts *)model{
    
    _model = model;
    
    model.isAnimation = NO;
    self.price.text = model.partner_price;
    self.name.text = model.name;
    self.MPView.model = model;
    self.selectBtn.selected = model.selected;
    
    
    [self.icon sd_setImageWithURL:[NSURL URLWithString:model.img]];
   
    if (model.is_xf.intValue == 1) {
        self.jx_weight.constant = 42;
        self.name_leading.constant = 47;
        self.jx_label.text = @"精 选";
    }else{
        self.jx_weight.constant = 0;
        self.name_leading.constant = 0;
        self.jx_label.text = @"";
    }

}



- (IBAction)selected:(UIButton *)sender {

    sender.selected = !sender.selected;
    
    self.model.selected = sender.selected;
    
//    [[NSNotificationCenter defaultCenter]postNotificationName:@"refrash" object:self];

    [[LBPlusMinusTool sharedPlusMinusTool]fastUpdate:self];
}



@end
